export function changeDataFormat(params) {
  const keys = Object.keys(params)
  var dimensions = []
  var target = []

  if (keys[0] === 'x' && keys[1] === 'y') {
    dimensions = params.x
    target = params.y
  } else if (keys[0] === 'dimension' && keys[1] === 'target') {
    dimensions = params.dimension
    target = params.target
  }
  const dimensionsData = dimensions.map(e => ({ ID: e.id, Name: e.name }))

  const targetData = target.map(e => ({ ID: e.id, Name: e.name, Type: 1 }))
  const columns = [...dimensions, ...target]

  var tableColumns = columns.map(e => ({
    label: e.name,
    prop: e.id,
  }))

  return { dimensionsData, targetData, dimensions, target, tableColumns }
}
